public class Solution {
    public int massage(int[] nums) {
        int len = nums.length;

        if (len == 0) {
            return 0;
        }

        int[] f = new int[len];//选
        int[] g = new int[len];//不选

        //初始化
        f[0] = nums[0];

        for (int i = 1; i < len; i++) {
            f[i] = g[i - 1] + nums[i];
            g[i] = Math.max(f[i - 1], g[i - 1]);
        }

        return Math.max(f[len - 1], g[len - 1]);
    }
}
